<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    	<title>统战成员学习平台</title>
	    <link rel="stylesheet" type="text/css" href="../../css/base.css" />
	    <link rel="stylesheet" type="text/css" href="../../css/discovery.css" />
	</head>
	<body>
		<div id='app' class="paddt" style="display:none" v-show="true">
			<div class="update_form">
				<span>原始密码</span>
				<input v-model="originalPwd" type="password" placeholder="原始密码">
			</div>
			<div class="update_form ui_border_t">
				<span>新密码</span>
				<input v-model="newPwd" type="password" placeholder="新密码">
			</div>
			<div class="update_form ui_border_t">
				<span>确认密码</span>
				<input v-model="renewPwd" type="password" placeholder="确认密码">
			</div>
			<div @click="submit()" class="big_btn" style="bottom: 3rem;">确定</div>
		</div>
		<script type="text/javascript" src="../../script/api.js"></script>
		<script type="text/javascript" src="../../script/vue.min.js"></script>
		<script type="text/javascript" src="../../script/common.js"></script>
		<script type="text/javascript" src="../../script/layer_mobile/layer.js"></script>
		<script type="text/javascript">
		    new Vue({
				el: '#app',
		     	data: {
					originalPwd: '',
					newPwd: '',
					renewPwd: ''
		     	},
				mounted: function() {
		        	var $this = this;
		        	apiready = function() {
						api.parseTapmode();
                	}
		    	},
		    	methods: {
					submit: function() {
						var $this = this;
						if(!$this.originalPwd.length) return msgUtil.toast({msg: '请输入原始密码'});
						if(!$this.newPwd.length) return msgUtil.toast({msg: '请输入新密码'});
						if($this.newPwd.length >=6 && $this.newPwd.length <= 20){
			        		var num1 = /.*[A-Z]+.*/.test($this.newPwd)?1:0; //是否有大写字母
			              	var num2 = /.*[a-z]+.*/.test($this.newPwd)?1:0;// 检查小写字母
			              	var num3 = /.*[0-9]+.*/.test($this.newPwd)?1:0;// 检查数字
			              	var num4 = /.*[^a-zA-Z0-9_]+.*/.test($this.newPwd)?1:0;// 检查特殊字符
			              	var chineseFlag = /.*[\u4e00-\u9fa5]+.*/.test($this.newPwd);//中文
			              	if(chineseFlag){
			              		return msgUtil.toast({msg: '密码不能包含中文字符'});
			              	}else{
			              		if(num1+num2+num3+num4 < 2) {
									return msgUtil.toast({msg: '新密码至少由数字、字母或符号的2种组合组成'});
								}
			              	}
			        	} else {
			        		return msgUtil.toast({msg: '新密码长度为6-20位'});
			        	}
						if(!$this.renewPwd.length) return msgUtil.toast({msg: '请输入确认密码'});
						if($this.newPwd != $this.renewPwd) return msgUtil.toast({msg: '确认密码与新密码不一致'});
						if($this.originalPwd === $this.newPwd) return msgUtil.toast({msg: '新密码不能与原始密码相同'});
						post('/client/user/changePwd', {
							originalPwd: MD5($this.originalPwd),
							newPwd: MD5($this.newPwd),
							renewPwd: MD5($this.renewPwd)
						}, function(ret) {
							msgUtil.toast({
							    msg: ret.message
							});
							if(ret.isSuccess) {
								setTimeout(function() {
									closeWin()
								}, 1000)
							}
						})
					}
		    	}
		    });
		</script>
	</body>
</html>
